package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.annotation.AutoFill;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {


    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from sky_take_out.employee where username = #{username}")
    Employee getByUsername(String username);
    @AutoFill(OperationType.INSERT)
    @Insert("insert into sky_take_out.employee values (null,#{name},#{username},#{password}," +
            "#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Employee employee);


    /**
     * 根据员工姓名查询
     *
     * @param name
     * @return
     */
    List<Employee> findByName(String name);
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);

    /**
    * 根据id查询员工信息
    * */

    @Select("select * from sky_take_out.employee where id = #{id}")
    Employee findById(Long id);
}
